package oo

import (
	"errors"
	"github.com/elliotchance/pie/v2"
	"strings"
)

type SubstringV7 struct {
	String
}

func (o *SubstringV7) Ints() ([]int, error) {
	ss := o.split()

	var number Number
	if !pie.All(ss, number.IsInt) {
		return nil, errors.New("one of numbers is not an integer")
	}

	return pie.Ints(ss), nil
}

func (o *SubstringV7) split() []string {
	return strings.Split(o.value, ",")
}
